// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from 'axios';
Vue.prototype.axios = axios
import $cookies from 'vue-cookies'
import vueWechatTitle from 'vue-wechat-title';
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import 'element-ui/lib/theme-chalk/index.css'
import "./assets/basejs/base"
import common from "./assets/basejs/common"
Vue.prototype.common = common;
import api from "./assets/basejs/config"
Vue.prototype.api = api;
Vue.use($cookies)
Vue.use(ElementUI)
// cnpm install vue-wechat-title --save
axios.defaults.withCredentials = true;

Vue.config.productionTip = false
Vue.use(vueWechatTitle);

import VueAliplayerV2 from 'vue-aliplayer-v2';
Vue.use(VueAliplayerV2);
let startApp = function() {
    var url = "";
    console.log(process.env.NODE_ENV)
    if (process.env.NODE_ENV == "dev") {
        url = '/static/config-dev.json';
    } else if (process.env.NODE_ENV == "test") {
        url = '/static/config-test.json';
    } else if (process.env.NODE_ENV == "prod") {
        url = '/static/config-prod.json';
    }

    axios.get(url).then(function(res) {
        api.setConfig(res.data);
        var vue = new Vue({
            el: '#app',
            router,
            components: {
                App
            },
            template: '<App/>'
        });

        router.beforeEach((to, from, next) => {
            /*路由发生改变修改页面的title */
            if (to.meta.title) {
                document.title = to.meta.title
            }
            next();
        });

    });
}
startApp()
